<%@page import="cn.util.Const"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>

<!DOCTYPE html>
<html lang="zh">
<head>
    <title>宠物用品管理系统</title>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="shortcut icon" type="image/x-icon" href="<%=Const.ROOT %>assets/images/favicon.png"/>
    <link rel="stylesheet" href="<%=Const.ROOT %>assets/css/bootstrap.min.css">
    <link rel="stylesheet" href="<%=Const.ROOT %>assets/css/font-awesome.min.css">
    <link rel="stylesheet" href="<%=Const.ROOT %>assets/css/owl.carousel.min.css">
    <link rel="stylesheet" href="<%=Const.ROOT %>assets/css/animate.min.css">
    <link rel="stylesheet" href="<%=Const.ROOT %>assets/css/jquery-ui.css">
    <link rel="stylesheet" href="<%=Const.ROOT %>assets/css/slick.css">
    <link rel="stylesheet" href="<%=Const.ROOT %>assets/css/chosen.min.css">
    <link rel="stylesheet" href="<%=Const.ROOT %>assets/css/pe-icon-7-stroke.css">
    <link rel="stylesheet" href="<%=Const.ROOT %>assets/css/magnific-popup.min.css">
    <link rel="stylesheet" href="<%=Const.ROOT %>assets/css/lightbox.min.css">
    <link rel="stylesheet" href="<%=Const.ROOT %>assets/js/fancybox/source/jquery.fancybox.css">
    <link rel="stylesheet" href="<%=Const.ROOT %>assets/css/jquery.scrollbar.min.css">
    <link rel="stylesheet" href="<%=Const.ROOT %>assets/css/mobile-menu.css">
    <link rel="stylesheet" href="<%=Const.ROOT %>assets/fonts/flaticon/flaticon.css">
    <link rel="stylesheet" href="<%=Const.ROOT %>assets/css/style.css">
</head>
<body class="productsgrid-page">
<%@include file="inc/header.jsp" %>
<div class="site-content">
    <main class="site-main  main-container no-sidebar">
        <div class="container">
            <div class="breadcrumb-trail breadcrumbs">
                <ul class="trail-items breadcrumb">
                    <li class="trail-item trail-begin">
                        <a href="">
								<span>
									首页
								</span>
                        </a>
                    </li>
                    <li class="trail-item trail-end active">
							<span>
								我的订单
							</span>
                    </li>
                </ul>
            </div>
            <div class="row">
                <div class="main-content-cart main-content col-sm-12">
                    <h3 class="custom_blog_title">
                        我的订单
                    </h3>
                    <div class="page-main-content">
                        <div class="shoppingcart-content">
                            <form action="shoppingcart.html" class="cart-form">
                                <table class="table">
                                    <thead>
                                    <tr>
                                        <th>序号</th>
                                        <th>商品</th>
                                        <th>总价</th>
                                        <th>下单时间</th>
                                        <th>状态</th>
                                        <th>操作</th>
                                    </tr>
                                    </thead>
                                    <tbody>
                                    <c:forEach items="${list }" var="v" varStatus="st">
                                    <tr>
                                        <td>
                                            ${st.count }
                                        </td>
                                        <td>
                                           <c:forEach items="${v.details}" var="vd">
                                           		<div>
                                           			${vd.goods.name} - ${vd.quantity}
                                           		</div>
                                           </c:forEach>
                                        </td>
                                        <td>
                                           ${v.price}
                                        </td>
                                        <td>
                                           ${v.optime}
                                        </td>
                                         <td>
                                            ${v.status}
                                        </td>
                                        <td>
                                        <c:if test="${v.status=='已发货' }">
			                            	<button class="btn btn-xs btn-primary" onclick="shouhuo(${v.id})">收货</button>
			                          	</c:if>
			                          	<c:if test="${v.status=='已收货' }">
			                            	<button class="btn btn-xs btn-primary" onclick="sq(${v.id})">申请退货</button>
			                          	</c:if>
											<button type="button" class="btn-danger btn-sm">删除</button>
                                        </td>
                                    </tr>
                                    </c:forEach>
                                    
                                    </tbody>
                                </table>
                            </form>
                           
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </main>
</div>
<%@include file="inc/footer.jsp" %>
<script src="<%=Const.ROOT %>assets/js/jquery-1.12.4.min.js"></script>
<script src="<%=Const.ROOT %>assets/js/jquery.plugin-countdown.min.js"></script>
<script src="<%=Const.ROOT %>assets/js/jquery-countdown.min.js"></script>
<script src="<%=Const.ROOT %>assets/js/bootstrap.min.js"></script>
<script src="<%=Const.ROOT %>assets/js/owl.carousel.min.js"></script>
<script src="<%=Const.ROOT %>assets/js/magnific-popup.min.js"></script>
<script src="<%=Const.ROOT %>assets/js/isotope.min.js"></script>
<script src="<%=Const.ROOT %>assets/js/jquery.scrollbar.min.js"></script>
<script src="<%=Const.ROOT %>assets/js/jquery-ui.min.js"></script>
<script src="<%=Const.ROOT %>assets/js/mobile-menu.js"></script>
<script src="<%=Const.ROOT %>assets/js/chosen.min.js"></script>
<script src="<%=Const.ROOT %>assets/js/slick.js"></script>
<script src="<%=Const.ROOT %>assets/js/jquery.elevateZoom.min.js"></script>
<script src="<%=Const.ROOT %>assets/js/jquery.actual.min.js"></script>
<script src="<%=Const.ROOT %>assets/js/fancybox/source/jquery.fancybox.js"></script>
<script src="<%=Const.ROOT %>assets/js/lightbox.min.js"></script>
<script src="<%=Const.ROOT %>assets/js/owl.thumbs.min.js"></script>
<script src="<%=Const.ROOT %>assets/js/jquery.scrollbar.min.js"></script>
<script src="<%=Const.ROOT %>assets/js/frontend-plugin.js"></script> 
<script>
function addCart(){
	var quantity=$("#quantity").val();
	$.getJSON("<%=Const.ROOT %>carts",{"action":"add","quantity":quantity,"gid":'${goods.id}'},function(data){
		console.log(data);
		if(data.code==200){
			alert("添加成功!");
		}
	});
}	
function updateCarts(cid,val){
	$.getJSON("<%=Const.ROOT %>carts",{"action":"update","quantity":val,"id":cid},function(data){
		if(data.code==200){
			location.reload();
		}
	});
}
function shouhuo(id){
	if(confirm("是否收货?")){
		$.getJSON("<%=Const.ROOT %>orders",{"action":"update","id":id,"status":"已收货"},function(data){
			if(data.code==200){
				location.reload();
			}
		});
	}
}
function sq(id){
	if(confirm("是否申请退出?")){
		$.getJSON("<%=Const.ROOT %>orders",{"action":"update","id":id,"status":"申请退货"},function(data){
			if(data.code==200){
				location.reload();
			}
		});
	}
}
function del(id){
	if(confirm("是否删除?")){
		$.getJSON("<%=Const.ROOT %>carts",{"action":"delete","id":id},function(data){
			if(data.code==200){
				location.reload();
			}
		});
	}
}
</script>
</body>
</html>